package com.chenxin.interact.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.chenxin.common.annotation.Log;
import com.chenxin.common.core.controller.BaseController;
import com.chenxin.common.core.domain.AjaxResult;
import com.chenxin.common.enums.BusinessType;
import com.chenxin.interact.domain.UrlMap;
import com.chenxin.interact.service.IUrlMapService;
import com.chenxin.common.utils.poi.ExcelUtil;
import com.chenxin.common.core.page.TableDataInfo;

/**
 * 系统路径Controller
 *
 * @author gry
 * @date 2025-04-23
 */
@RestController
@RequestMapping("/interact/urlMap")
public class UrlMapController extends BaseController {
    @Autowired
    private IUrlMapService urlMapService;

/**
 * 查询系统路径列表
 */
@PreAuthorize("@ss.hasPermi('interact:urlMap:list')")
@GetMapping("/list")
    public TableDataInfo list(UrlMap urlMap) {
        startPage();
        List<UrlMap> list = urlMapService.selectUrlMapList(urlMap);
        return getDataTable(list);
    }

    /**
     * 导出系统路径列表
     */
    @PreAuthorize("@ss.hasPermi('interact:urlMap:export')")
    @Log(title = "系统路径", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, UrlMap urlMap) {
        List<UrlMap> list = urlMapService.selectUrlMapList(urlMap);
        ExcelUtil<UrlMap> util = new ExcelUtil<UrlMap>(UrlMap. class);
        util.exportExcel(response, list, "系统路径数据");
    }

    /**
     * 获取系统路径详细信息
     */
    @PreAuthorize("@ss.hasPermi('interact:urlMap:query')")
    @GetMapping(value = {"/", "/{urlId}"})
    public AjaxResult getInfo(@PathVariable(value = "urlId", required = false) Long urlId) {
        return success(urlMapService.selectUrlMapByUrlId(urlId));
    }

    /**
     * 新增系统路径
     */
    @PreAuthorize("@ss.hasPermi('interact:urlMap:add')")
    @Log(title = "系统路径", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody UrlMap urlMap) {
        return toAjax(urlMapService.insertUrlMap(urlMap));
    }

    /**
     * 修改系统路径
     */
    @PreAuthorize("@ss.hasPermi('interact:urlMap:edit')")
    @Log(title = "系统路径", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody UrlMap urlMap) {
        return toAjax(urlMapService.updateUrlMap(urlMap));
    }

    /**
     * 删除系统路径
     */
    @PreAuthorize("@ss.hasPermi('interact:urlMap:remove')")
    @Log(title = "系统路径", businessType = BusinessType.DELETE)
    @DeleteMapping("/{urlIds}")
    public AjaxResult remove(@PathVariable Long[] urlIds) {
        return toAjax(urlMapService.deleteUrlMapByUrlIds(urlIds));
    }
}
